package com.wef.system.service.impl;

import java.util.Iterator;
import java.util.List;

import com.gfa4j.hibernate.BaseObject;
import com.gfa4j.service.impl.BaseServiceImpl;
import com.wef.system.entity.AclConfigEntry;
import com.wef.system.service.AclConfigEntryService;

public class AclConfigEntryServiceImpl extends BaseServiceImpl implements AclConfigEntryService {

	public AclConfigEntry saveOrUpdateAclConfigEntry(AclConfigEntry aclConfigEntry) {
		if (aclConfigEntry.getRowStatus() == BaseObject.ROWSTATUS_ADDED){
			return (AclConfigEntry)saveObject(aclConfigEntry);
		}
		if (aclConfigEntry.getRowStatus() == BaseObject.ROWSTATUS_UNCHANGED){
			return aclConfigEntry;
		}
		if (aclConfigEntry.getRowStatus() == BaseObject.ROWSTATUS_MODIFIED){
			return (AclConfigEntry)updateObject(aclConfigEntry);
		}
		if (aclConfigEntry.getRowStatus() == BaseObject.ROWSTATUS_DELETED){
			deleteObject(aclConfigEntry);
			return null;
		}
		return aclConfigEntry;
	}

	public List saveOrUpdateAclConfigEntrys(List<AclConfigEntry> aclConfigEntrys) {
		for (Iterator it = aclConfigEntrys.iterator(); it.hasNext();) {
			AclConfigEntry eachAclConfigEntry = (AclConfigEntry) it.next();
			int rowStatus = eachAclConfigEntry.getRowStatus();
			saveOrUpdateAclConfigEntry(eachAclConfigEntry);
			if (rowStatus == BaseObject.ROWSTATUS_DELETED)
				it.remove();
		}
		return aclConfigEntrys;
	}

}
